SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for equ_subject
-- ----------------------------
DROP TABLE IF EXISTS `equ_subject`;
CREATE TABLE `equ_subject`
(
    `id`             bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '编号',
    `name`           varchar(250)   DEFAULT '' COMMENT '项目名称',
    `parent_id`      bigint(20)    DEFAULT NULL COMMENT '父编码',
    `standard_id`    varchar(20)    DEFAULT NULL COMMENT '标准编码',
    `model`          varchar(250)   DEFAULT '' COMMENT '型号',
    `specifications` varchar(250)   DEFAULT '' COMMENT '规格',
    `price`          decimal(10, 2) DEFAULT NULL COMMENT '单价',
    `unit`           varchar(30)    DEFAULT NULL COMMENT '计量单位',
    `type`           varchar(10)    DEFAULT NULL COMMENT '类型',
    `create_by`      varchar(64)    DEFAULT '' COMMENT '创建者',
    `create_time`    datetime       DEFAULT NULL COMMENT '创建时间',
    `update_by`      varchar(64)    DEFAULT '' COMMENT '更新者',
    `update_time`    datetime       DEFAULT NULL COMMENT '更新时间',
    `delete_time`    datetime       DEFAULT NULL COMMENT '删除时间',
    `remark`         varchar(500)   DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `parent_id` (`parent_id`) USING BTREE,
    INDEX `standard_id` (`standard_id`) USING BTREE,
    INDEX `type` (`type`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='设备类型表';

-- ----------------------------
-- Records of equ_subject
-- ----------------------------
BEGIN;
COMMIT;


-- ----------------------------
-- Table structure for equ_warehouse
-- ----------------------------
DROP TABLE IF EXISTS `equ_warehouse`;
CREATE TABLE `equ_warehouse`
(
    `id`          bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '编号',
    `name`        varchar(100) DEFAULT '' COMMENT '仓库名称',
    `type_id`     varchar(10) NOT NULL COMMENT '类型编码',
    `dept_id`     bigint(20)   default null comment '部门ID',
    `manager_id`  bigint(20)   DEFAULT NULL COMMENT '保管员ID',
    `create_by`   varchar(64)  DEFAULT '' COMMENT '创建者',
    `create_time` datetime     DEFAULT NULL COMMENT '创建时间',
    `update_by`   varchar(64)  DEFAULT '' COMMENT '更新者',
    `update_time` datetime     DEFAULT NULL COMMENT '更新时间',
    `delete_time` datetime     DEFAULT NULL COMMENT '删除时间',
    `remark`      varchar(500) DEFAULT NULL COMMENT '备注',
    INDEX `type_id` (`type_id`) USING BTREE,
    INDEX `dept_id` (`dept_id`) USING BTREE,
    INDEX `manager_id` (`manager_id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='仓库表';

-- ----------------------------
-- Records of equ_subject
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for equ_warehouse_type
-- ----------------------------
DROP TABLE IF EXISTS `equ_warehouse_type`;
CREATE TABLE `equ_warehouse_type`
(
    `id`          varchar(10) NOT NULL COMMENT '编号',
    `name`        varchar(100) DEFAULT '' COMMENT '名称',
    `create_by`   varchar(64)  DEFAULT '' COMMENT '创建者',
    `create_time` datetime     DEFAULT NULL COMMENT '创建时间',
    `update_by`   varchar(64)  DEFAULT '' COMMENT '更新者',
    `update_time` datetime     DEFAULT NULL COMMENT '更新时间',
    `delete_time` datetime     DEFAULT NULL COMMENT '删除时间',
    `remark`      varchar(500) DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='仓库类型表';

-- ----------------------------
-- Records of equ_warehouse_type
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for equ_equipment
-- ----------------------------
DROP TABLE IF EXISTS `equ_equipment`;
CREATE TABLE `equ_equipment`
(
    `id`             bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '编号',
    `name`           varchar(250)   DEFAULT '' COMMENT '项目名称',
    `model`          varchar(250)   DEFAULT '' COMMENT '型号',
    `specifications` varchar(250)   DEFAULT '' COMMENT '规格',
    `price`          decimal(10, 2) DEFAULT NULL COMMENT '单价',
    `unit`           varchar(30)    DEFAULT NULL COMMENT '计量单位',
    `subject_id`     varchar(30) NOT NULL COMMENT '设备类型编码',
    `create_by`      varchar(64)    DEFAULT '' COMMENT '创建者',
    `create_time`    datetime       DEFAULT NULL COMMENT '创建时间',
    `update_by`      varchar(64)    DEFAULT '' COMMENT '更新者',
    `update_time`    datetime       DEFAULT NULL COMMENT '更新时间',
    `delete_time`    datetime       DEFAULT NULL COMMENT '删除时间',
    `remark`         varchar(500)   DEFAULT NULL COMMENT '备注',
    INDEX `subject_id` (`subject_id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='设备类型表';

-- ----------------------------
-- Records of equ_equipment
-- ----------------------------
BEGIN;
COMMIT;


-- ----------------------------
-- Table structure for equ_account
-- ----------------------------
DROP TABLE IF EXISTS `equ_account`;
CREATE TABLE `equ_account`
(
    `id`             bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
    `subject_id`     varchar(30)    DEFAULT '' COMMENT '设备类型ID',
    `model`          varchar(250)   DEFAULT '' COMMENT '型号',
    `specifications` varchar(250)   DEFAULT 'crud' COMMENT '使用的模板（crud单表操作 tree树表操作）',
    `price`          decimal(10, 2) DEFAULT NULL COMMENT '单价',
    `num`            decimal(10, 2) DEFAULT NULL COMMENT '数量',
    `charge`         decimal(14, 2) DEFAULT NULL COMMENT '金额',
    `unit`           varchar(30)    DEFAULT NULL COMMENT '计量单位',
    `dept_id`        bigint(20)     default null comment '部门ID',
    `warehouse_id`   bigint(20)     default null comment '仓库ID',
    `standard_num`   decimal(10, 2) DEFAULT NULL COMMENT '标准数量',
    `cabinet_no`     varchar(64)    DEFAULT '' COMMENT '柜号',
    `layer_no`       varchar(64)    DEFAULT '' COMMENT '层号',
    `qc_num`         decimal(10, 2) DEFAULT NULL COMMENT '期初数量',
    `qc_charge`      decimal(14, 2) DEFAULT NULL COMMENT '期初金额',
    `in_num`         decimal(10, 2) DEFAULT NULL COMMENT '入库数量',
    `in_charge`      decimal(14, 2) DEFAULT NULL COMMENT '入库金额',
    `out_num`        decimal(10, 2) DEFAULT NULL COMMENT '出库数量',
    `out_charge`     decimal(14, 2) DEFAULT NULL COMMENT '出库金额',
    `consume_num`    decimal(10, 2) DEFAULT NULL COMMENT '报损数量',
    `consume_charge` decimal(14, 2) DEFAULT NULL COMMENT '报损金额',
    `used_num`       decimal(10, 2) DEFAULT NULL COMMENT '消耗数量',
    `used_charge`    decimal(14, 2) DEFAULT NULL COMMENT '消耗金额',
    `lock_num`       decimal(10, 2) DEFAULT NULL COMMENT '锁定数量',
    `lock_charge`    decimal(14, 2) DEFAULT NULL COMMENT '锁定金额',
    `create_by`      varchar(64)    DEFAULT '' COMMENT '创建者',
    `create_time`    datetime       DEFAULT NULL COMMENT '创建时间',
    `update_by`      varchar(64)    DEFAULT '' COMMENT '更新者',
    `update_time`    datetime       DEFAULT NULL COMMENT '更新时间',
    `delete_time`    datetime       DEFAULT NULL COMMENT '删除时间',
    `remark`         varchar(500)   DEFAULT NULL COMMENT '备注',
    INDEX `subject_id` (`subject_id`) USING BTREE,
    INDEX `dept_id` (`dept_id`) USING BTREE,
    INDEX `warehouse_id` (`warehouse_id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='设备台帐表';

-- ----------------------------
-- Records of equ_account
-- ----------------------------
BEGIN;
COMMIT;


-- ----------------------------
-- Table structure for equ_his_account
-- ----------------------------
DROP TABLE IF EXISTS `equ_his_account`;
CREATE TABLE `equ_his_account`
(
    `id`                bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
    `settle_account_id` bigint(20)     DEFAULT null COMMENT '扎帐ID',
    `account_id`        bigint(20)     DEFAULT null COMMENT '台帐ID',
    `subject_id`        varchar(30)    DEFAULT '' COMMENT '设备类型ID',
    `model`             varchar(250)   DEFAULT '' COMMENT '型号',
    `specifications`    varchar(250)   DEFAULT 'crud' COMMENT '使用的模板（crud单表操作 tree树表操作）',
    `price`             decimal(10, 2) DEFAULT NULL COMMENT '单价',
    `num`               decimal(10, 2) DEFAULT NULL COMMENT '数量',
    `charge`            decimal(14, 2) DEFAULT NULL COMMENT '金额',
    `unit`              varchar(30)    DEFAULT NULL COMMENT '计量单位',
    `dept_id`           bigint(20)     default null comment '部门ID',
    `warehouse_id`      bigint(20)     default null comment '仓库ID',
    `standard_num`      decimal(10, 2) DEFAULT NULL COMMENT '标准数量',
    `cabinet_no`        varchar(64)    DEFAULT '' COMMENT '柜号',
    `layer_no`          varchar(64)    DEFAULT '' COMMENT '层号',
    `qc_num`            decimal(10, 2) DEFAULT NULL COMMENT '期初数量',
    `qc_charge`         decimal(14, 2) DEFAULT NULL COMMENT '期初金额',
    `in_num`            decimal(10, 2) DEFAULT NULL COMMENT '入库数量',
    `in_charge`         decimal(14, 2) DEFAULT NULL COMMENT '入库金额',
    `out_num`           decimal(10, 2) DEFAULT NULL COMMENT '调拨出库数量',
    `out_charge`        decimal(14, 2) DEFAULT NULL COMMENT '调拨出库金额',
    `consume_num`       decimal(10, 2) DEFAULT NULL COMMENT '报损数量',
    `consume_charge`    decimal(14, 2) DEFAULT NULL COMMENT '报损金额',
    `used_num`          decimal(10, 2) DEFAULT NULL COMMENT '消耗数量',
    `used_charge`       decimal(14, 2) DEFAULT NULL COMMENT '消耗金额',
    `borrow_num`        decimal(10, 2) DEFAULT NULL COMMENT '领用数量',
    `borrow_charge`     decimal(14, 2) DEFAULT NULL COMMENT '领用金额',
    `create_by`         varchar(64)    DEFAULT '' COMMENT '创建者',
    `create_time`       datetime       DEFAULT NULL COMMENT '创建时间',
    `update_by`         varchar(64)    DEFAULT '' COMMENT '更新者',
    `update_time`       datetime       DEFAULT NULL COMMENT '更新时间',
    `delete_time`       datetime       DEFAULT NULL COMMENT '删除时间',
    `remark`            varchar(500)   DEFAULT NULL COMMENT '备注',
    INDEX `settle_account_id` (`settle_account_id`) USING BTREE,
    INDEX `account_id` (`account_id`) USING BTREE,
    INDEX `dept_id` (`dept_id`) USING BTREE,
    INDEX `warehouse_id` (`warehouse_id`) USING BTREE,
    INDEX `subject_id` (`subject_id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='历史设备台帐表';

-- ----------------------------
-- Records of equ_account
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for equ_settle_account
-- ----------------------------
DROP TABLE IF EXISTS `equ_settle_account`;
CREATE TABLE `equ_settle_account`
(
    `id`          bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
    `begin_time`  date         DEFAULT NULL COMMENT '开始日期',
    `end_time`    date         DEFAULT NULL COMMENT '结束日期',
    `create_by`   varchar(64)  DEFAULT '' COMMENT '创建者',
    `create_time` datetime     DEFAULT NULL COMMENT '创建时间',
    `update_by`   varchar(64)  DEFAULT '' COMMENT '更新者',
    `update_time` datetime     DEFAULT NULL COMMENT '更新时间',
    `delete_time` datetime     DEFAULT NULL COMMENT '删除时间',
    `remark`      varchar(500) DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='台帐扎帐表';

-- ----------------------------
-- Records of equ_settle_account
-- ----------------------------
BEGIN;
COMMIT;


-- ----------------------------
-- Table structure for equ_io_type
-- ----------------------------
DROP TABLE IF EXISTS `equ_io_type`;
CREATE TABLE `equ_io_type`
(
    `id`            varchar(2)   NOT NULL COMMENT '编号',
    `name`          varchar(30)  NULL DEFAULT '' COMMENT '业务名称',
    `in_out`        int(0)       NULL DEFAULT 0 COMMENT '出入库，-1出库，1入库，0不影响存量',
    `inner`         int(0)       NULL DEFAULT 0 COMMENT '是否内部流转，0：否，1：是',
    `account_field` varchar(10)  NULL DEFAULT '' COMMENT '台账字段',
    `create_by`     varchar(64)  NULL DEFAULT '' COMMENT '创建者',
    `create_time`   datetime(0)  NULL DEFAULT NULL COMMENT '创建时间',
    `update_by`     varchar(64)  NULL DEFAULT '' COMMENT '更新者',
    `update_time`   datetime(0)  NULL DEFAULT NULL COMMENT '更新时间',
    `delete_time`   datetime(0)  NULL DEFAULT NULL COMMENT '更新时间',
    `remark`        varchar(500) NULL DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '设备业务类别表'
  ROW_FORMAT = Dynamic;

BEGIN;
INSERT INTO `equ_io_type` (`id`, `name`, `in_out`, `inner`, `account_field`, `create_by`, `create_time`, `update_by`,
                           `update_time`)
VALUES ('01', '入库', 1, 0, 'in', 'admin', NOW(), 'admin', NOW());
INSERT INTO `equ_io_type` (`id`, `name`, `in_out`, `inner`, `account_field`, `create_by`, `create_time`, `update_by`,
                           `update_time`)
VALUES ('02', '校间调拨', -1, 0, 'out', 'admin', NOW(), 'admin', NOW());
INSERT INTO `equ_io_type` (`id`, `name`, `in_out`, `inner`, `account_field`, `create_by`, `create_time`, `update_by`,
                           `update_time`)
VALUES ('03', '校内调拨', -1, 0, 'out', 'admin', NOW(), 'admin', NOW());
INSERT INTO `equ_io_type` (`id`, `name`, `in_out`, `inner`, `account_field`, `create_by`, `create_time`, `update_by`,
                           `update_time`)
VALUES ('04', '报损', -1, 0, 'consume', 'admin', NOW(), 'admin', NOW());
INSERT INTO `equ_io_type` (`id`, `name`, `in_out`, `inner`, `account_field`, `create_by`, `create_time`, `update_by`,
                           `update_time`)
VALUES ('05', '消耗', -1, 0, 'used', 'admin', NOW(), 'admin', NOW());
INSERT INTO `equ_io_type` (`id`, `name`, `in_out`, `inner`, `account_field`, `create_by`, `create_time`, `update_by`,
                           `update_time`)
VALUES ('06', '消耗', 0, 1, 'borrow', 'admin', NOW(), 'admin', NOW());
COMMIT;

-- ----------------------------
-- Table structure for equ_io
-- ----------------------------
DROP TABLE IF EXISTS `equ_io`;
CREATE TABLE `equ_io`
(
    `id`              bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '编号',
    `io_no`           varchar(30)      DEFAULT '' COMMENT '单据编号',
    `io_type_id`      varchar(20)      DEFAULT '' COMMENT '单据类型编号',
    `io_mode`         varchar(20)      DEFAULT '' COMMENT '出入库方式',
    `dept_id`         bigint(20)       default null comment '部门ID',
    `warehouse_id`    bigint(20)       default null comment '仓库ID',
    `to_dept_id`      bigint(20)       default null comment '调往部门ID',
    `to_warehouse_id` bigint(20)       default null comment '调往仓库ID',
    `user_id`         bigint(20)       default null comment '登记人ID',
    `create_by`       varchar(64)      DEFAULT '' COMMENT '创建者',
    `create_time`     datetime         DEFAULT NULL COMMENT '创建时间',
    `update_by`       varchar(64)      DEFAULT '' COMMENT '更新者',
    `update_time`     datetime         DEFAULT NULL COMMENT '更新时间',
    `delete_time`     datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `remark`          varchar(500)     DEFAULT NULL COMMENT '备注',
    `image_url`       varchar(500)     DEFAULT NULL COMMENT '图片',
    INDEX `io_no` (`io_no`) USING BTREE,
    INDEX `io_type_id` (`io_type_id`) USING BTREE,
    INDEX `dept_id` (`dept_id`) USING BTREE,
    INDEX `warehouse_id` (`warehouse_id`) USING BTREE,
    INDEX `user_id` (`user_id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='业务主表';



-- ----------------------------
-- Table structure for equ_io_detail
-- ----------------------------
DROP TABLE IF EXISTS `equ_io_detail`;
CREATE TABLE `equ_io_detail`
(
    `id`             bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '编号',
    `io_id`          bigint(20)  NOT NULL COMMENT '单据ID',
    `subject_id`     varchar(30)      DEFAULT '' COMMENT '设备类型ID',
    `model`          varchar(250)     DEFAULT '' COMMENT '型号',
    `specifications` varchar(250)     DEFAULT '' COMMENT '规格',
    `price`          decimal(10, 2)   DEFAULT NULL COMMENT '单价',
    `num`            decimal(10, 2)   DEFAULT NULL COMMENT '数量',
    `charge`         decimal(14, 2)   DEFAULT NULL COMMENT '金额',
    `unit`           varchar(30)      DEFAULT NULL COMMENT '计量单位',
    `create_by`      varchar(64)      DEFAULT '' COMMENT '创建者',
    `create_time`    datetime         DEFAULT NULL COMMENT '创建时间',
    `update_by`      varchar(64)      DEFAULT '' COMMENT '更新者',
    `update_time`    datetime         DEFAULT NULL COMMENT '更新时间',
    `delete_time`    datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `remark`         varchar(500)     DEFAULT NULL COMMENT '备注',
    INDEX `io_id` (`io_id`) USING BTREE,
    INDEX `subject_id` (`subject_id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='业务明细表';

-- ----------------------------
-- Table structure for equ_edu_standard
-- ----------------------------
DROP TABLE IF EXISTS `equ_edu_standard`;
CREATE TABLE `equ_edu_standard`
(
    `id`             bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '编号',
    `subject_id`     varchar(30)      DEFAULT '' COMMENT '设备类型ID',
    `num1`          decimal(10, 2)   DEFAULT NULL COMMENT '标准1',
    `num2`          decimal(10, 2)   DEFAULT NULL COMMENT '标准2',
    `num3`          decimal(10, 2)   DEFAULT NULL COMMENT '标准3',
    `num4`          decimal(10, 2)   DEFAULT NULL COMMENT '标准4',
    `study_id`      varchar(10) NOT NULL COMMENT '学科ID',
    `type`           varchar(10)      DEFAULT NULL COMMENT '类型：选配，标配',
    `create_by`      varchar(64)      DEFAULT '' COMMENT '创建者',
    `create_time`    datetime         DEFAULT NULL COMMENT '创建时间',
    `update_by`      varchar(64)      DEFAULT '' COMMENT '更新者',
    `update_time`    datetime         DEFAULT NULL COMMENT '更新时间',
    `delete_time`    datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `remark`         varchar(500)     DEFAULT NULL COMMENT '备注',
    INDEX `io_id` (`study_id`) USING BTREE,
    INDEX `subject_id` (`subject_id`) USING BTREE,
    INDEX `create_time` (`create_time`) USING BTREE,
    INDEX `delete_time` (`delete_time`) USING BTREE,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC COMMENT ='教育技术装备标准表';


SET FOREIGN_KEY_CHECKS = 1;
